home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2000 #4 / Amiga Plus CD - 2000 - No. 4.iso / Tools / DFUE / Aminet-AWNP / Aminet.awnp < prev    next >
Encoding:
Text File  |  2000-04-18  |  22.8 KB  |  699 lines

  1. /* Program Written By Bruce Steers <bsteers@ukonline.co.uk> */
  2. ver='$VER: Aminet.awnp 1.9 (18.04.00)'
  3.  
  4. /* Using AWNPipe by William Parker <Bill@amitrix.com> */
  5. /* AND Clipper By Bruce Steers <bsteers@ukonline.co.uk> */
  6.  
  7. vern=word(ver,3)
  8.  
  9. if ~show('l','rexxsupport.library') then call addlib('rexxsupport.library',0,-30,0)
  10. if ~show('l','rexxdossupport.library') then call addlib('rexxdossupport.library',0,-30,0)
  11. if ~showlist(h,'AWNPIPE') then address command 'mount awnpipe:'
  12. if ~showlist(h,'AWNPIPE') then do; say locales(MSG_Errorwith)' Awnpipe: Device..' ; exit(1); end
  13. ibase=showlist(l,'intuition.library',,a)
  14. call forbid; scrA=next(ibase,56)
  15. scrW=c2d(IMPORT(offset(scrA,12),2))
  16. scrH=c2d(IMPORT(offset(scrA,14),2))
  17. screen=word(IMPORT(next(scrA,26)),1)
  18. call permit
  19. WIN='0 10 'scrW' 100'
  20. PWIN='0 10 'scrW' 100'
  21. parse source . . . prog .
  22. lp=max(lastpos('/',prog),lastpos(':',prog))
  23. parse var prog progpath +lp progname
  24. progname=strip(progname)
  25. prefsname=progpath'Aminet.awnp.cfg'
  26. LF='0A'x ; CRLF='0A0D'x
  27. chprf=0; noget=1;  wait=0
  28. parse value with NAME SetIn
  29.  
  30. call BuildStrings()
  31. call getfont()
  32. call loadprefs()
  33.  
  34. parse arg args
  35.  if args=='?' then do;
  36.    if index(address(),'AMIRC.')==1 then do
  37.    'echo Aminet.awnp By Bruce Steers'
  38.    'echo ReadArgs Help..'
  39.    'echo 'locales(MSG_ArgHelp)'      NAME,LENGTH/N,DIR/K,SITE/N,README/T,ASKDIR/T,BUBBLE/T,WAIT/S'
  40.    exit
  41.    end
  42.    else do
  43.    call writech(STDOUT,locales(MSG_ArgHelp) || LF'NAME,LENGTH/N,DIR/K,SITE/N,README/T,ASKDIR/T,BUBBLE/T,WAIT/S,WIN/K,PWIN/K : ')
  44.    args=readln(STDIN)
  45.    end
  46.  end
  47. call readargs(args,'NAME,LENGTH/N,DIR/K,SITE/N,README/T,ASKDIR/T,BUBBLE/T,WAIT/S,WIN/K,PWIN/K')
  48.  
  49. call storedefs()
  50.  
  51. call buildgui()
  52.  
  53. if (name~='') & wait==0 then do; call topipe('id 0 s 256'); call searchfunc; call topipe('id 'lvw' list 1'); call topipe('id 'inf' defn 0 gt "'labinfo'"'); call topipe('id 0 s 512'); call topipe('id 'ptn' s 0'); end
  54.  
  55.  do while ~eof(pipe)
  56.  call writeln(pipe,'id 0 read'); WIN=readln(pipe);
  57.  call topipe('con')
  58.  in=readln(pipe)
  59.  parse var in in1 in2 in3 in4 in5 in6
  60.   select
  61.   when in1=='' then nop
  62.   when in1=='iconify' then call topipe('id 0 s '64-(32*in2))
  63.   when in1=='menu' then call menu()
  64.   when in1=='close' then nop
  65.   when in1=='help' then if bubble==1 then call help()
  66.   when in1=='gadget' then call gadget()
  67.   otherwise say in
  68.   end
  69.  end
  70. if chprf | (O_LENGTH==LENGTH & O_PWIN==PWIN & O_WIN==WIN & O_README==README & O_DIR==DIR & O_ASKDIR==ASKDIR & O_SITE==SITE & O_BUBBLE==BUBBLE)==0 then
  71. if req('"" "'locales(MSG_ChPrf)'"') then call saveprefs()
  72. call close(pipe)
  73. exit(0)
  74.  
  75. menu:
  76. select
  77. when in3==0 then call req('"" "Aminet.awnp*n'ver'*n*nBruce Steers <bsteers@ukonline.co.uk>*n*nhttp://web.ukonline.co.uk/bsteers/*nhttp://web.ukonline.co.uk/awnpipe/" "'locales(MSG_OK)'"')
  78. when in3==2 then do; if in5==0 & bubble==1 then call topipe('bubble'); bubble=in5; end
  79. when in3==4 then call prefs()
  80. when in3==6 then call newver()
  81. when in3==8 then exit
  82. otherwise nop
  83. end
  84. return
  85.  
  86. gadget:
  87. select
  88. when in2==xit then nop /*do; address command 'run rx 'prog; exit; end*/
  89. when in2==prf then call prefs()
  90. when in2==sch then do; call topipe('id 0 s 256'); call searchfunc; call topipe('id 'lvw' list 1'); call topipe('id 'inf' defn 0 gt "'labinfo'"'); call topipe('id 0 s 512'); call topipe('id 'ptn' s 0'); end
  91. when in2==get then do; call topipe('id 0 s 256'); call getfile(); call topipe('id 0 s 512'); end
  92. when in2==sng then do; site=in3+1; parse var ams.site '://'amd'/' .; end
  93. when in2==ptn then do; parse var in . . name; name=strip(name); if name=='' then do; call topipe('id 'sch' dis 1'); return; end; call topipe('id 'sch' dis 0'); end
  94. when in2==hit then length=in3
  95. when in2==rec then call recent()
  96. when in2==rme then readme=in3
  97. when in2==dlp then askdir=in3
  98. when in2==vrm then call viewr()
  99.  
  100. when in2==lvw then do
  101. if noget then do; noget=0; call topipe('id 'get' dis 0');call topipe('id 'vrm' dis 0'); end
  102. nodeat=bnode.in5
  103. nodein=in5
  104. parse var nodes.nodeat.line amname amtype .
  105. if in3==16 then do
  106. ans=req('"" "'locales(MSG_SELFUNC)'" gadgets "'locales(MSG_VIEWR)'" "'locales(MSG_GET)'" "'locales(MSG_ABORT)'"')
  107. if ans==1 then call viewr()
  108. if ans==2 then call getfile()
  109. end
  110. end
  111. otherwise nop
  112. end
  113. return
  114.  
  115. help:
  116. if in2>0 then; call topipe('bubble top 'in3' left 'in4' gt "'hlp.in2'"')
  117. else; call topipe('bubble')
  118. return
  119.  
  120. mhlp:
  121. hlp.rec=locales(HLP_REC)
  122. hlp.inf=locales(HLP_INF)
  123. hlp.xit=locales(HLP_XIT)
  124. hlp.sch=locales(HLP_SCH)
  125. hlp.vrm=locales(HLP_VRM)
  126. hlp.get=locales(HLP_GET)
  127. hlp.ptn=locales(HLP_PTN)
  128. hlp.hit=locales(HLP_HIT)
  129. hlp.rme=locales(HLP_RME)
  130. hlp.dlp=locales(HLP_DLP)
  131. hlp.sng=locales(HLP_SNG)
  132. hlp.lvw=locales(HLP_LVW)
  133. return
  134.  
  135. buildgui:
  136. labinfo='Bruce Steers <bsteers@ukonline.co.uk>'
  137. if ~open(pipe,'awnpipe:Aminet.awnp/xc') then exit(2)
  138.  
  139. parse var WIN winl wint winw winh .
  140. call topipe('"Aminet.awnp 'locales(MSG_SEARCHFIND) vern' Bruce" defg left 'winl' top 'wint' width 'winw' height 'winh' a v si so h m ig it "AmFind.Zzz" ii "'prog'" ps "'screen'" st "Aminet.awnp 'locales(MSG_SEARCHFIND) vern' By Bruce Steers <bsteers@ukonline.co.uk>"')
  141. if bubble then ch='&'; else; ch='%'
  142. men=locales(MNU_MENU)
  143. men=translate(men,ch,'¶')
  144.  
  145. call writeln(pipe,'TextAttr gt "'gfont'" defn 'gfsize'');tmp=readln(pipe); parse var tmp . gfontid gfontA .
  146. call writeln(pipe,'TextAttr gt "'lfont'" defn 'lfsize'');tmp=readln(pipe); parse var tmp . lfontid lfontA .
  147.  
  148. call topipe('menu gt "'men'"')
  149.  
  150. rqg =topipe('getfile ua save fn "'dir'" i dr gt "'locales(DL_PATH)'"')
  151.  
  152. call topipe('layout weih 0 b 5')
  153. inf =topipe('FuelGauge cj gt "'labinfo'" defn 0 maxn 100')
  154. call topipe('le')
  155. lvw =topipe('listbrowser font 'lfontid' tc noms weih 100 st a v lbl "'locales(MSG_LISTLABELS)'"')
  156. call topipe('layout weih 0 font 'gfontid' b 0 si so')
  157. rec =topipe('button tc weiw 0 gt "'locales(MSG_RECENT)'"')
  158. vrm =topipe('button tc weiw 0 gt "'locales(MSG_README)'" dis 1')
  159. get =topipe('button tc weiw 0 gt "'locales(MSG_GET)'" dis 1')
  160. sch =topipe('button tc weiw 0 gt "'locales(MSG_SEARCH)'" dis 1')
  161. ptn =topipe('string tc lj gt "'name'"')
  162. call topipe('label gt "*n*n 'locales(LAB_MAXHITS)':"')
  163. hit =topipe('integer tc minn 1 maxn 500 weiw 0 minc 3 defn 'length' a')
  164. call topipe('le')
  165.  
  166. call topipe('layout font 'gfontid' weih 0 b 0 so')
  167. call topipe('label gt "*n*n  'locales(LAB_GetR)':"')
  168. rme =topipe('checkbox s 'readme'')
  169. call topipe('label gt "*n*n  'locales(LAB_ASKD)':"')
  170. dlp =topipe('checkbox s 'askdir'')
  171. call topipe('label gt "  "')
  172. sng =topipe('chooser s 'site-1' tc pu cl 'do_srvlst()'')
  173. call topipe('label gt "  "')
  174. xit =topipe('button font='gfontid' tc weiw 0 gt "'locales(MSG_QUIT)'" c')
  175. call topipe('le')
  176.  
  177. call topipe('open')
  178. call mhlp()
  179. call topipe('id 'ptn' s 0')
  180. return
  181.  
  182. do_srvlst:
  183. srvlst='"'
  184. do c=1 to ams0;
  185. parse var ams.c '://'adr'/' .
  186. srvlst=srvlst'('c')'copies(' ',2-length(c))||adr'|'; end
  187. srvlst=substr(srvlst,1,length(srvlst)-1)'"'
  188. return srvlst
  189.  
  190. topipe:
  191. parse arg out
  192. call writeln(pipe,out); res=readln(pipe)
  193. parse var res res1 res2 .
  194. if res1='ok' then return(res2)
  195. say 'error from: 'out; say '  responce: ' res; exit
  196.  
  197.  
  198. searchfunc:
  199. sport='tcp:'amd'/1848'
  200. call clear()
  201. call topipe('id 'lvw' list 0');
  202. call setinf(locales(MSG_CON2)' 'amd)
  203.   if open(1,sport,'W') then do;
  204.   call setinf(locales(MSG_OKSENDING))
  205.   call writeln(1,'max 'length)
  206.   call writeln(1,'find 'name)
  207.   call writeln(1,'max')
  208.   setinf(locales(MSG_READREP))
  209.   preinf=locales(MSG_SEARCHING)
  210.     do until eof(1)
  211.     text=readln(1)
  212.     if text='Missing argument.' then leave
  213.       if left(text,27)='*** No matching files found' then do
  214.       call req('"" "'name locales(MSG_NOMATCH)'" "'locales(MSG_OK)'"')
  215.         call close(1)
  216.       return
  217.       end
  218.       if index(text,'*** Additional matches omitted.')==1 then do
  219.       call req('"" "'locales(MSG_MORETHAN) || length')" "'locales(MSG_OK)'"')
  220.        call close(1)
  221.       return
  222.       end
  223.       else do;
  224.       call addn(text)
  225.       end
  226.     end
  227.   end
  228. else; call req('"" "'locales(MSG_ERROR)'*n'locales(MSG_CON2)'*n'amd'!" "'locales(MSG_OK)'"');
  229.  
  230. call close(1)
  231. call setinf(locales(MSG_SEARCHEND))
  232. return
  233.  
  234. clear:
  235. drop nodes.
  236. drop bnode.
  237. cnt=0
  238. call topipe('id 'lvw' s 0')
  239. call topipe('id 'lvw' remn')
  240. call topipe('id 'get' dis 1')
  241. call topipe('id 'vrm' dis 1')
  242. noget=1
  243. return
  244.  
  245. addn:
  246.     outt=space(arg(1),1)
  247.     do c=1 to 4; p=index(outt,' '); outt=delstr(outt,p,1); outt=insert('|',outt,p-1); end
  248.     outt=restr(outt)
  249.     nn = topipe('id 'lvw' addn gt "'outt'"')
  250.     cnt=cnt+1
  251.     nodes.cnt.node=nn
  252.     nodes.cnt.line=arg(1)
  253.     bnode.nn=cnt
  254.     if arg(2)=='' then call updateguage(cnt,length)
  255. return
  256.  
  257. restr: PROCEDURE; rt=arg(1)
  258. p=1; do while p>0;
  259. p=index(rt,'*',p);
  260. if p~=0 then do
  261. rt=insert('*',rt,p-1);
  262. p=p+2
  263. end
  264. end
  265. return rt
  266.  
  267. setinf:
  268. if arg(1)~='' then call topipe('id 'inf' gt "'arg(1)'"')
  269. else; call topipe('id 'inf' defn 0 gt "'labinfo'"')
  270. return(0)
  271.  
  272. updateguage:
  273.  per = 100 * ( arg(1) / arg(2) ) ;
  274.  dotp = index(per,'.'); if dotp~=0 then per=left(per,dotp-1)
  275.  call topipe('id 'inf' defn 'per' gt "'preinf'('per'%) 'arg(1)'/'arg(2)'"')
  276. return
  277.  
  278. getfile:
  279. if askdir then; if ~reqdir(dir) then return
  280. if ~download(ams.site||amtype'/'amname) then return
  281. if readme then if ~download(ams.site||amtype'/'substr(amname,1,length(amname)-3)'readme') then return
  282. call topipe('id 'nodein' remn');
  283. call topipe('id 'get' dis 1');
  284. call topipe('id 'vrm' dis 1');
  285. nodeat=0
  286. noget=1
  287. return
  288.  
  289. download:
  290. parse arg url
  291. if right(dir,1)~=':' then if right(dir,1)~='/' then dir=dir'/'
  292. lp=max(lastpos(':',url),lastpos('/',url))
  293. parse var url ddir +lp filename .
  294. parse var url '://'serv'/' .
  295.  
  296. call setinf(locales(MSG_CON2) serv'...')
  297. if ~open(infile,'tcp:'serv'/80','W') then do; call req('"" "'locales(MSG_ERROR)'*n'locales(MSG_CON2)'*n'serv'!" "'locales(MSG_OK)'"'); return 0; end
  298.  
  299. call setinf(locales(MSG_GETTING) URL)
  300. call setinf(locales(MSG_SAVEAS) dir||filename'.')
  301. call writech(infile,'GET 'url 'HTTP/1.0'||CRLF)
  302. call writech(infile,CRLF)
  303. if ~open(outfile,dir || filename,'W') then do; call close(infile);
  304. call req('"" "'locales(MSG_ERROR)'*n'locales(MSG_SAVEAS)'*n'path'" "'locales(MSG_OK)'"'); return 0; end
  305. size=0; afile=0 ; flines=0
  306.  do until eof(infile)
  307.   IF afile==0 then do
  308.   ln=readln(infile);
  309.    select
  310.    when index(upper(ln),'CONTENT-LENGTH:')==1 then do; max=substr(ln,17); max=compress(max,crlf); end
  311.    when index(upper(ln),'CONTENT-TYPE:')==1 then do; type=substr(ln,15); type=compress(type,crlf); end
  312.     when ln=='
  313. ' then do; afile=1; preinf=type'.  '
  314.     end
  315.    otherwise nop
  316.    end
  317.   end
  318.  
  319.   else do;
  320.   olen = writech(outfile,readch(infile,1024))
  321.   size=size+olen
  322.   if olen~=0 then call updateguage(size,max)
  323.   end
  324.  end
  325.  
  326. call close(outfile) ; call close(infile)
  327.  call topipe('id 'inf' defn 0 gt "'labinfo'"');
  328. return 1
  329.  
  330. reqdir: call writeln(pipe,'id 'RQG' s 1'); res=readln(pipe); if res==0 then return 0; dir=strip(strip(delstr(res,1,2)),,'"'); return 1
  331.  
  332. req:
  333.  parse arg args
  334. PUBSCREEN=screen
  335. call readargs(args,'TITLE,BODY,GADGETS/M,PUBSCREEN/K')
  336. if title=="" |  title=='TITLE' then TITLE='Aminet.awnp';
  337. if body=="" | body=='BODY' then BODY='Are you sure ?'
  338. if GADGETS.COUNT==0 | GADGETS.COUNT=='GADGETS.COUNT' then do;
  339. GADGETS.0=locales(MSG_YES); GADGETS.1=locales(MSG_NO); GADGETS.COUNT=2; end
  340. if ~open('req','awnpipe:AWNPChoice'time(s)'/xc') then exit(2)
  341. call toreq('"'TITLE'" width 150 sk m db dg v a ps "'PUBSCREEN'"')
  342. p=1; do while p>0; p=index(body,'0A'X); if p~=0 then do; body=delstr(body,p,1); body=insert('*n',body,p-1); end; end
  343. call toreq('layout si so cj b 5'); call toreq('space'); call toreq('label gt "*n'body'*n" underscore="¿"'); call toreq('space'); call toreq('le')
  344. spos=toreq('layout cj si so b 1'); if GADGETS.COUNT == 1 then call toreq('space')
  345. do c=0 to GADGETS.COUNT - 1; call toreq('button weiw 0 gt "'GADGETS.c'" c'); end
  346. if GADGETS.COUNT == 1 then call toreq('space'); call toreq('le')
  347. call toreq('open')
  348.  do while ~eof('req')
  349.  call toreq('con')
  350.  in=readln('req')
  351.  parse var in in1 in2 in3 in4 in5
  352.   select
  353.   when in1=='gadget' then if in2==(spos + GADGETS.COUNT) then ans=0; else; ans=in2-spos
  354.    when in1=='key' & (in2==68 | in2==69) then do; ans=(in2==68);  call close('req'); return ans;end
  355.   otherwise nop
  356.   end
  357.  end
  358. call close('req')
  359. return ans
  360.  
  361. toreq: parse arg out; call writeln('req',out); res=readln('req'); parse var res res1 res2 .; if res1='ok' then return(res2); say 'error from: 'out; say '  responce: ' res; exit
  362.  
  363. infoline: if index(amname,'-------')==1 then; return 1; return 0
  364.  
  365. viewr:
  366.  
  367. if infoline() then return req('"" "'locales(MSG_ERROR)'*n'locales(MSG_NOFILESEL)'" "'locales(MSG_OK)'"')
  368. opath=dir
  369. dir='T:'
  370. rmename=substr(amname,1,length(amname)-3)'readme'
  371. if download(ams.site||amtype'/'rmename) then do
  372. call topipe('id 0 s 256')
  373. call topipe('id 'inf' defn 0')
  374. call open(vh,'awnpipe:viewreadme/xc')
  375. call writeln(vh,'"T:'rmename'" width 'scrw' height 200 tl cg dg sg db ig v a')
  376. call writeln(vh,'textfield gt 0 arrows ro bd datain "T:'rmename'"')
  377. call writeln(vh,'open')
  378.  
  379. do while ~eof(vh)
  380. call readln(vh)
  381. end
  382. call close(vh)
  383. call topipe('id 0 s 512')
  384. end
  385. call delete('t:'rmename)
  386. dir=opath
  387. return
  388.  
  389. prefs:
  390. call open(sh,'awnpipe:servers/xc')
  391. parse var PWIN pwinl pwint pwinw pwinh .
  392. call topipe('id 0 s 128')
  393. call topipe2('"'locales(MSG_AMIPRF)'" defg v a m left='pwinl' top='pwint' width='pwinw' height 'pwinh'')
  394. lb2 =topipe2('listbrowser a font 'lfontid' h st noms lbl "'locales(MSG_AMIADR)'"')
  395. htps =topipe2('string font 'gfontid' lj tc')
  396.   call topipe2('layout weih 0 font 'gfontid' si so b 5')
  397.   adg =topipe2('button gt "'locales(MSG_ADDSERV)'"')
  398.   rmg =topipe2('button gt "'locales(MSG_REMSERV)'"')
  399.   call topipe2('le')
  400. call topipe2('open')
  401. call snodes()
  402. call diss(1)
  403.  
  404.   do while ~eof(sh)
  405.   call writeln(sh,'id 0 read'); PWIN=readln(sh);
  406.   call topipe2('con')
  407.   ln=readln(sh)
  408.   parse var ln in1 in2 in3 in4 in5 in6 .
  409.   if in1=='gadget' then call sgads()
  410.   else; nop
  411.   end
  412. call close(sh)
  413. SetIn=""
  414. call topipe('id 0 s 64')
  415. return
  416.  
  417. sgads:
  418.  select
  419.  when in2==lb2 then call seld(in5)
  420.          when in2==htps then do
  421.              if in3~=ams.sat then do
  422.              ams.sat=in3
  423.             call topipe2('id 'SetIn' gt "'ams.sat'"')
  424.           call topipe('id 'sng' cl 'do_srvlst()'')
  425.           call topipe2('id 'lb2' sort 0')
  426.           call topipe2('id 'lb2' s 'SetIn'')
  427.              if sat==site then parse var ams.sat '://'amd'/' .
  428.              chprf=1
  429.              end
  430.         end
  431.      when in2==adg then do
  432.      ams0=ams0+1; ams.ams0='http://'
  433.      sat=ams0
  434.      nm=topipe2('id 'lb2' addn gt "'ams.ams0'"')
  435.      snode.nm=ams0
  436.      call topipe2('id 'lb2' s 'nm);call seld(nm)
  437.    call topipe('id 'sng' cl 'do_srvlst()'')
  438.    chprf=1
  439.      end
  440.  
  441.      when in2==rmg then do;
  442.      call topipe2('id 'lb2' s=0')
  443.      do c=sat to ams0; c1=c+1
  444.    if c==ams0 then ams.c=""
  445.    else; ams.c=ams.c1
  446.    end
  447.      ams0=ams0-1
  448.      call snodes()
  449.      call topipe('id 'sng' cl 'do_srvlst()'')
  450.      call topipe2('id 'htps' gt "" ref');
  451.      call diss(1);
  452.      SetIn=""
  453.      chprf=1;
  454.      end
  455.  otherwise nop
  456.  end
  457. return
  458.  
  459. snodes:
  460. drop snode.
  461. call topipe2('id 'lb2' remn');
  462. call topipe2('id 'lb2' list 0');
  463.  do c=1 to ams0
  464.  num=topipe2('id 'lb2' addn gt "'ams.c'"')
  465.  snode.num=c
  466.  end
  467. call topipe2('id 'lb2' list 1');
  468. return
  469.  
  470. seld:
  471.  if SetIn=="" then call diss(0)
  472.  SetIn=arg(1)
  473.  sat=snode.SetIn
  474.  call topipe2('id 'htps' gt "'ams.sat'" ref')
  475. return
  476.  
  477. diss:
  478. di=arg(1)
  479. call topipe2('id 'htps' dis 'di' ref')
  480. if ams.sat=="" | ams.ams0==1 then do; di=1; SetIn=""; end
  481. call topipe2('id 'rmg' dis 'di' ref')
  482. return
  483.  
  484. topipe2:
  485. parse arg out
  486. call writeln(sh,out); res=readln(sh)
  487. parse var res res1 res2 .
  488. if res1='ok' then return(res2)
  489. say 'error from: 'out; say '  responce: ' res; exit
  490.  
  491.  
  492. loadprefs:
  493.  if ~exists( prefsname ) then do
  494.  LENGTH=20; DIR='Ram:'; SITE=3; BUBBLE=1; README=1; ASKDIR=1; WIN='0 10 'scrW' 100';  PWIN='0 10 'scrW' 100';
  495.  
  496.  ams.1='http://ftp.uni-paderborn.de/~aminet/dirs/aminet/'
  497.  ams.2='http://ftp.wustl.edu/~aminet/dirs/aminet/'
  498.  ams.3='http://uk.aminet.net/aminet/dirs/aminet/'
  499.  ams0=3
  500.  if req('"" "'locales(MSG_NoPrf1)'*n'prefsname'*n'locales(MSG_NoPrf2)'"') then call saveprefs()
  501.  end
  502.  
  503.  if open(ph,prefsname) then do
  504.  pl=readln(ph)
  505.  call readargs(pl,'LENGTH/N,DIR/K,SITE/N,BUBBLE/T,README/T,ASKDIR/T,WIN/K,PWIN/K')
  506.  ams0=0
  507.   do while ~eof(ph)
  508.   ln=readln(ph)
  509.      if ln~="" then do
  510.      ams0=ams0+1
  511.      if index(ln,' ')~=0 then; parse var ln . ams.ams0 .
  512.      else; ams.ams0=ln
  513.      end
  514.   end
  515.   call close(ph)
  516.   end
  517.   site=min(ams0,max(site,1,site))
  518.   parse var ams.site '://'amd'/' .
  519.  
  520. call storedefs()
  521. return
  522.  
  523. saveprefs:
  524. if ~open(ph,prefsname,'W') then do; call req('"" "'locales(MSG_ERROR)'*n'locales(MSG_SAVEP)'" "'locales(MSG_OK)'"'); return; end;
  525. call writeln(ph,'LENGTH 'length' DIR 'dir' SITE 'site' BUBBLE='word('OFF ON',bubble+1)' README 'word('OFF ON',readme+1)' ASKDIR 'word('OFF ON',askdir+1)' WIN "'WIN'" PWIN "'PWIN'"')
  526. do c=1 to ams0
  527. call writeln(ph,ams.c)
  528. end
  529. call close(ph)
  530. return
  531.  
  532. storedefs:
  533. O_LENGTH=LENGTH
  534. O_README=README
  535. O_DIR=DIR
  536. O_ASKDIR=ASKDIR
  537. O_SITE=SITE
  538. O_BUBBLE=BUBBLE
  539. O_WIN=WIN
  540. O_PWIN=PWIN
  541. return
  542.  
  543. newver:
  544. opath=dir; got=0
  545. dir='T:'
  546.   if download('http://web.ukonline.co.uk/bsteers/versions.dat') then do
  547.   call open(dh,'t:versions.dat')
  548.     do while ~eof(dh) & got==0
  549.     dln=readln(dh)
  550.     if word(dln,2)=='Aminet.awnp' then got=1
  551.     end
  552.   call close(dh)
  553.   call delete('t:versions.dat')
  554.   if got==0 then do; dir=opath; call req('"" "'locales(MSG_NOVERINF)'" "'locales(MSG_OK)'"');return; end
  555.     if word(dln,3)>vern then do
  556.     st=locales(MSG_NEWVER)
  557.     st=insert(' 'word(dln,3),st,index(st,'*n')-1)
  558.       if req('"" "'st'" "'locales(MSG_DOWNLOAD)'" "'locales(MSG_LEAVE)'"') then do
  559.       if reqdir('ram:') then call download(substr(dln,index(dln,')')+2))
  560.       end
  561.     end
  562.   else;  call req('"" "'locales(MSG_LATEST)'" "'locales(MSG_OK)'"')
  563.   end
  564. dir=opath
  565. return
  566.  
  567. recent:
  568. opath=dir
  569. dir='T:'; day=2
  570. call clear()
  571.     if download(ams.site'RECENT') then do
  572.    call setinf(locales(MSG_READREC))
  573.     call open('th','T:RECENT')
  574.     call readln('th'); call readln('th'); call readln('th'); call readln('th'); call readln('th');
  575.     lines=0; locday=locales(MSG_DAY)
  576.     call topipe('id 'lvw' remn');
  577.     call topipe('id 'lvw' list 0');
  578.         call addn('-------'locday'-1------ ---        ---- --- ---'locday'-1---',0)
  579.         do while ~eof('th')
  580.         text=readln('th')
  581.         if substr(text,35,1)=='+' then do;           text=insert('  ',insert('  ',text,34),37); lines=lines+1; end
  582.          else do;if ~eof('th') then;text='-------'locday'-'day'------ ---        ---- --- ---'locday'-'day'---'; else; text='------------------ ---        ---- --- -----------'; day=day+1; end
  583.         call addn(text,0)
  584.         end
  585.     call topipe('id 'lvw' list 1');
  586.     call close('th')
  587.     call delete('t:RECENT')
  588.     end
  589.     else; call req('"" "'locales(MSG_ERROR)'*n'locales(MSG_NORECENT)'" "'locales(MSG_OK)'"')
  590. call setinf()
  591. dir=opath
  592. return
  593.  
  594.  
  595.  
  596. /*  Read default strings, open locale.library and catalog
  597. Thanks to Nils Goers for letting me use this code from his WB tool T.H.E
  598. */
  599.  
  600. BuildStrings:
  601.  
  602. CALL BuildInLanguage()            /* install build-in language */
  603.  
  604. IF ~SHOW('l','locale.library') THEN CALL ADDLIB('locale.library',0,-30,0)
  605.  
  606. IF SHOW('l','locale.library') THEN DO
  607.     catalog=0
  608.     id='req'pragma('id')                /* get current language */
  609.     address command 'rxset' id '`echo $language`'
  610.     language=getclip(id)
  611.     call setclip(id,'')
  612.    IF (language ~= '') & (language~='$language') THEN DO
  613.     catalog = OPENCATALOG(progpath'catalogs/'language'/Aminet.awnp.catalog','english',0)
  614.         IF catalog == 0 THEN
  615.     catalog = OPENCATALOG(progpath'Aminet.awnp.catalog','english',0)
  616.    END
  617.  
  618.    IF catalog == 0 THEN
  619.     catalog = OPENCATALOG('Aminet.awnp.catalog','english',0)
  620. END
  621. RETURN
  622.  
  623. locales:   PARSE ARG stringnumber
  624. IF stringnumber=="" then Return('LocaleErr')
  625.  IF catalog ~= 0 THEN; RETURN(GETCATALOGSTR(catalog,stringnumber,strings.stringnumber))
  626.  ELSE; RETURN(strings.stringnumber)
  627.  
  628. BuildInLanguage:
  629. MSG_ERRORWITH   = 0 ; strings.0  ='Error With.. '
  630. MSG_ARGHELP     = 1 ; strings.1  ='Args with /T are Toggle , eg, use README=ON to activate'
  631. MSG_NOPRF1      = 2 ; strings.2  ='did not find file'
  632. MSG_NOPRF2      = 3 ; strings.3  ='Should I Create a New one ?'
  633. MSG_CHPRF       = 4 ; strings.4  ='Settings Have Been Changed*nDo you want to Remember Changes'
  634. MSG_YES         = 5 ; strings.5  ='_Yes'
  635. MSG_NO          = 6 ; strings.6  ='_No'
  636. MSG_OK          = 7 ; strings.7  ='_OK'
  637. MSG_SELFUNC     = 8 ; strings.8  ='Select A function'
  638. MSG_VIEWR       = 9 ; strings.9  ='_View Readme'
  639. MSG_GET         = 10; strings.10 ='_Get'
  640. MSG_ABORT       = 11; strings.11 ='_Abort'
  641. MSG_SEARCHFIND  = 12; strings.12 ='Searcher/Finder'
  642. MNU_MENU        = 13; strings.13 ='Main|@?About Aminet.awnp|-|@B^¶Bubble Help|-|@SServers|-|@Vcheck www for Newer Version|-|@QQuit'
  643. MSG_DL_PATH     = 14; strings.14 ='Download Path'
  644. MSG_LISTLABELS  = 15; strings.15 ='Archive Name|Type|Size|Age|Info'
  645. MSG_RECENT      = 16; strings.16 ='Re_cent'
  646. MSG_SEARCH      = 17; strings.17 ='_Search'
  647. LAB_MAXHITS     = 18; strings.18 ='MaxHits'
  648. MSG_README      = 19; strings.19 ='_Readme'
  649. LAB_GETR        = 20; strings.20 ='Get Readme'
  650. LAB_ASKD        = 21; strings.21 ='Ask For Dir'
  651. MSG_QUIT        = 22; strings.22 ='_Quit'
  652. MSG_CON2        = 23; strings.23 ='Connecting to'
  653. MSG_OKSENDING   = 24; strings.24 ='Connected .. Sending search info'
  654. MSG_READREP     = 25; strings.25 ='Reading Replies'
  655. MSG_SEARCHING   = 26; strings.26 ='Searching ....'
  656. MSG_NOMATCH     = 27; strings.27 ='*nThis name did not return any matches*n(OR maybe the server isn''t Working ?)'
  657. MSG_MORETHAN    = 28; strings.28 ='Note...*nSearch found more entries than*nthe Specified ('
  658. MSG_SEARCHEND   = 29; strings.29 ='Search Has Finished...'
  659. MSG_GETTING     = 30; strings.30 ='Getting'
  660. MSG_SAVEAS      = 31; strings.31 ='Saving As'
  661. MSG_NOFILESEL   = 32; strings.32 ='You Don''t have a file selected!'
  662. MSG_ERROR       = 33; strings.33 ='Error !!!'
  663. MSG_AMIPRF      = 34; strings.34 ='Aminet Server Settings'
  664. MSG_AMIADR      = 35; strings.35 ='Addresses of Aminet Sites'
  665. MSG_ADDSERV     = 36; strings.36 ='_Add New Server'
  666. MSG_REMSERV     = 37; strings.37 ='_Remove Server'
  667. MSG_SAVEP       = 38; strings.38 ='Saving Prefs'
  668. MSG_NOVERINF    = 39; strings.39 ='An unknown error has occured :(*nCan not find any*ninfo for this program.'
  669. MSG_NEWVER      = 40; strings.40 ='A Newer Version*nIs Currently Available :)'
  670. MSG_DOWNLOAD    = 41; strings.41 ='_Download'
  671. MSG_LEAVE       = 42; strings.42 ='_Leave Alone'
  672. MSG_LATEST      = 43; strings.43 ='You have the Latest Version :)'
  673. MSG_INCHITS     = 44; strings.44 ='hits may not be enough for the whole RECENT file*nShould it be Increased to a temporary length of 300 ?'
  674. MSG_NORECENT    = 45; strings.45 ='Unable to download RECENT file :('
  675. MSG_DAY         = 46; strings.46 ='Day'
  676. HLP_REC             = 47; strings.47 ='View the last 7 days*nRecent Uploads list'
  677. HLP_INF             = 48; strings.48 ='Info window'
  678. HLP_XIT             = 49; strings.49 ='Quit program'
  679. HLP_SCH             = 50; strings.50 ='Start Search'
  680. HLP_VRM             = 51; strings.51 ='Read the Readme file'
  681. HLP_GET             = 52; strings.52 ='Download Selected File'
  682. HLP_PTN             = 53; strings.53 ='Set search string'
  683. HLP_HIT             = 54; strings.54 ='Maximum number of results'
  684. HLP_RME             = 55; strings.55 ='Also get Readme file'
  685. HLP_DLP             = 56; strings.56 ='Ask for new Download path'
  686. HLP_SNG             = 57; strings.57 ='Aminet Site'
  687. HLP_LVW             = 58; strings.58 ='Archive List'
  688. MSG_READREC         = 59; strings.59 ='Parsing RECENT File'
  689. RETURN
  690.  
  691. getfont:
  692. lfont='Topaz.font' lfsize=8; gfont='Topaz.font' ; gfsize=8;
  693. call open(th,'awnpipe:tooltypes/xi'prog)
  694. DO while ~eof(th)
  695. tln=readln(th)
  696. IF index(upper(tln),'GADGET_FONT=')==1 then parse var tln +12 gfont'/'gfsize .
  697. IF index(upper(tln),'LIST_FONT=')==1 then parse var tln +10 lfont'/'lfsize .
  698. end
  699. return
  700.